/******************************************************************* DOS.c Shows the usage of LaunchCLI() and LaunchWB(), ... Time to be again a little bit lazy :-), because it is all simple stuff... For testing -> remember the command is hidden. *********************************************************************/ #define PARENT #include "/includes/Project.h" #define HIDDEN_TEMPLATE "WB/K,CLI/K,NAME/K,VERSION/K" // With // - WB we do start a program in Workbench mode // - CLI start a program in CLI mode // - NAME does set an ENV variable "TEST" with the devicename/path of a file // - (ie. you enter "_hiddencommand_ NAME=WorkBench/disk.info" // ENV:TEST will be "HD0:disk.info" ) // Note: Sorry, for now you must use DOpus or whatever manually to see // the result of this action. // Later we could solve it ... :-) // - VERSION tries to get this information and shows it within a requester // Each command needs of course supplied a file/program // Argument passing to the programs to launch we do not here..., it would // only require to append them to the program name, but I am sure you know // how... :-) void HiddenCommand( STRPTR args, IPCData *ipc, IPCData *main_ipc ) { // normally this count of variables should be enough to allocate // the memory, but forgive me here ... :-) // I want not make the includes to much heavy for the beginners FuncArgs *fargs; char buffer[256], day[16], date[16], time[16]; BPTR lock; short version, revision; struct DateTime dt; if( (fargs = ParseArgs(HIDDEN_TEMPLATE, args)) ) { if( fargs->FA_Arguments[0] ) // Launch WB { LaunchWBNew( (STRPTR) fargs->FA_Arguments[0], // program or even a guide, ... NULL, // use default screen FALSE, // do return immediate 4096, // default stack (does not override an icon) "MultiView" ); // default tool ( " " " " " ) // done :-) } if( fargs->FA_Arguments[1] ) // Launch CLI { LaunchCLI( (STRPTR) fargs->FA_Arguments[1], // program to launch NULL, // use default screen NULL, // we have no lock... NULL, NULL, // we have also no input/output channels LAUNCHF_WAIT, // here our program should wait for the program ends // It does of course only work, if the program does not // detach itself ! NULL ); // we didn't supply the LAUNCHF_STACK flag // (else you should specify here the stack to use) } if( fargs->FA_Arguments[2] ) // "Show" device/path { // we does set a default, if Lock() does fail strcpy( buffer, "Lock() has failed" ); if( (lock = Lock( (STRPTR) fargs->FA_Arguments[2], SHARED_LOCK)) ) { DevNameFromLock( lock, // lock to file/directory buffer, // string buffer to store the result 256 ); // size of string buffer UnLock( lock ); } // So let's do the next DOpus-DOS routine // KEEP THIS IN MIND - it is very useful to search failures SetEnv( "TEST", // name of the ENV variable buffer, // string buffer containing the value FALSE ); // set this to TRUE, if the variable should // be created/overwritten in ENVARC: too } if( fargs->FA_Arguments[3] ) // Get version/info { GetFileVersion( (STRPTR) fargs->FA_Arguments[3], // filename &version, // pointer to receive the version number &revision, // same for revision &dt.dat_Stamp, // DateStamp to get the creation date (if possible) NULL ); // we does not supply a progress handle (now...) // NOTE: I do not check here, if the time was valid. // You may do a little bit finetuning here... :-) dt.dat_Format = FORMAT_DOS; dt.dat_Flags = 0; dt.dat_StrDay = day; dt.dat_StrDate = date; dt.dat_StrTime = time; DateToStr( &dt ); sprintf( buffer, "Filename: %s\nVersion: %ld\nRevision: %ld\nCreation: %s on %s the %s", fargs->FA_Arguments[3], version, revision, time, day, date ); AsyncRequestTags( ipc, // our ipc REQTYPE_SIMPLE, // a simple requester NULL, // just open on default screen NULL, // no refresh callback NULL, // like before AR_Message, buffer, // our "output" AR_Button, DOpusGetString(locale, MSG_OKAY), TAG_DONE ); } DisposeArgs( fargs ); } }